!function () {
    var loginName = $('#loginName'), loginKey = $('#loginKey'), loginKeytwo = $('#loginKeytwo'),
        name = $('#name'), Email = $('#Email'), telephone = $('#telephone'), phone = $('#phone'),
        leavemsg = $('#leavemsg'), register = $('.register')
    phone.on('input',function(){
        if(phone.val()>0){
        }else{
            phone.val('')
        }
    })
    //点击注册校验
    register.on('click', function () {
        if (loginName.val() == '') {
            loginName.siblings().fadeIn()
            return
        } else {
            loginName.siblings().fadeOut()
        }
        if (loginKey.val() == '') {
            loginKey.siblings().fadeIn()
            return
        } else {
            loginKey.siblings().fadeOut()
        }
        if (loginKeytwo.val() != loginKey.val()) {
            loginKeytwo.siblings().fadeIn()
            return
        } else {
            loginKeytwo.siblings().fadeOut()
        }
        if (name.val() == '') {
            name.siblings().fadeIn()
            return
        } else {
            name.siblings().fadeOut()
        }
        if (phone.val() == '') {
            phone.siblings().fadeIn()
            return
        } else {
            phone.siblings().fadeOut()
        }
        $.ajax({
            url:'http://localhost/80edu/api.php/records/users',
            method:'post',
            data:{
                loginName:loginName.val(),
                loginKey:loginKey.val(),
                name:name.val(),
                phone:phone.val(),
                age:'',
                gender:'',
                adress:'',
                status:'1',
                type:'0'
            },
            success:function(data){
                console.log(data)
                location.href = 'login.html'
            }
        })
    })
}()